
/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "操作记录.h"


static std::vector<C_操作记录*> g_记录;
static uint32					g_记录堆栈ID = 0;
static uint32					g_记录堆栈顶 = 0;



C_操作记录::C_操作记录() {
	if (g_记录堆栈ID >= g_记录.size()) {
		g_记录.push_back(this);
		++g_记录堆栈顶;
	}
	else {

		g_记录[g_记录堆栈ID] = this;
		uint32 num = g_记录.size();

		g_记录堆栈顶 = g_记录堆栈ID + 1;
		for (uint32 i = g_记录堆栈顶; i < num; ++i) {
			delete g_记录[i];

			g_记录[i] = nullptr;
		}

	}
	
	++g_记录堆栈ID;
}

void C_操作记录::f_撤销() {
	
}

void C_操作记录::f_重做() {

}








E_事件是否传递 f_操作记录_全局撤销(C_Widget* self, uint8 状态) {
	if (g_记录堆栈ID) {
		--g_记录堆栈ID;
		g_记录[g_记录堆栈ID]->f_撤销();
	}
	return E_事件是否传递::e_事件传递_终止;
}

E_事件是否传递 f_操作记录_全局重做(C_Widget* self, uint8 状态) {
	if (g_记录堆栈ID < g_记录堆栈顶) {
		g_记录[g_记录堆栈ID]->f_重做();
		++g_记录堆栈ID;
	}
	return E_事件是否传递::e_事件传递_终止;
}



